<?php
class IndexController extends BaseController {
	
	public function indexAction() {
		$menu = array();
		$menu[] = array('name'=>__('文章管理'), 'url'=>URL('post.index'));
		$menu[] = array('name'=>__('评论管理'), 'url'=>URL('comment.index'));
		$menu[] = array('name'=>__('链接管理'), 'url'=>URL('link.index'));
		$menu[] = array('name'=>__('标签管理'), 'url'=>URL('tag.index'));
		$menu[] = array('name'=>__('附件管理'), 'url'=>URL('attach.index'));
		$menu[] = array('name'=>__('用户管理'), 'url'=>URL('user.index'));
		$menu[] = array('name'=>__('页面管理'), 'url'=>URL('page.index'));
		$menu[] = array('name'=>__('主题管理'), 'url'=>URL('theme.index'));
		$menu[] = array('name'=>__('插件管理'), 'url'=>URL('plugin.index'));
		$menu[] = array('name'=>__('系统设置'), 'url'=>URL('setting.index'));
		$menu[] = array('name'=>__('数据维护'), 'url'=>URL('data.index'));
		$menu[] = array('name'=>__('个人中心'), 'url'=>URL('account.index'));
		$this->assign('menu', $menu);
		$this->display();
	}
	
	public function mainAction() {
		$dbSize = 0;
		$result = $this->db->getList("SHOW TABLE STATUS LIKE '".$this->db->getPrefix()."%'");
		foreach ($result as $table) {
			$dbSize += $table['Data_length'] + $table['Index_length'];
		}
		$dbSize = $dbSize ? File::sizeFormat($dbSize) : 'unknown';
		$attachSize = $this->db->getOne("SELECT SUM(filesize) FROM ".$this->db->getTable('attach'));
		$attachSize = $attachSize ? File::sizeFormat($attachSize) : '0';
		$postNum = $this->db->count($this->db->getTable('post'), "`type` = 'blog'");
		$commentNum = $this->db->count($this->db->getTable('comment'));
		$userNum = $this->db->count($this->db->getTable('user'));
		$maxUpload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknown';
		$registerGlobals = @ini_get('register_globals') ? 1 : 0;
		$gdVersion = function_exists('gd_info') ? (is_array($gd=gd_info()) ? $gd['GD Version'] : '') : 'unknown';
		$stat = array(
				'dbSize' => $dbSize,
				'attachSize' => $attachSize,
				'postNum' => $postNum,
				'commentNum' => $commentNum,
				'userNum' => $userNum,
				'serverInfo' => $this->input->getServer('SERVER_SOFTWARE'),
				'mysqlVersion' => $this->db->version(),
				'blogname' => JBlog::config('blog.name'),
				'blogurl' => JBlog::config('blog.url'),
				'gdVersion' => $gdVersion,
				'registerGlobals' => $registerGlobals,
				'maxUpload' => $maxUpload,
		);
		$this->assign($stat);
		$this->display();
	}
	
	public function phpinfoAction() {
		phpinfo();
	}
}
?>
